<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent">
    <img
      class="outline-parent-bg"
      :src="publicUrls + 'free/style16/Auxiliaryoutlinestyle3Bg.webp'"
      alt=""
    />
    <div
      class="outline-right"
      v-if="props.info.audio && props.info.audio.url"
      :class="audioFlag && 'rotate'"
      @click="audioplay"
    >
      <div class="right-content"></div>
    </div>
    <div class="outline border-hover-style">
      <div class="outline-title">
        <div class="outline-title-content" v-html="textType(props.info.text)"></div>
      </div>
      <div class="outline-content">
        <p class="outline-subTitle" v-if="props.info.subTitle">——{{ props.info.subTitle }}</p>
        <TextMax
          v-if="props.info && props.domShow"
          :data="props.info.remarks"
          :title="props.info.text"
          :row="props.info.value && props.info.subTitle ? 3 : !props.info.value && props.info.subTitle ? 6 : 8"
        ></TextMax>
        <div class="medium" v-if="props.info.value || (props.info.video && props.info.video.url)">
          <img
            v-if="!(props.info.video && props.info.video.url)"
            class="outline-cover"
            @click="ImgVisible = true"
            :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
            alt=""
          />
          <videoview :info="props.info"></videoview>
        </div>
      </div>

      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free16Style3',
});
</script>

<script setup lang="ts">
import videoview from './../../../videoDialog/videoview.vue';
import { publicUrls, textType } from '@/utils/minxin';
import textMode from '../../../textMode/textMode.vue';
import { urls } from '@/utils/request/upload';
import { defineComponent, onMounted, ref, watch } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import { useProjectStore } from '@/store';

const ImgVisible = ref(false);
const visible = ref(false);
const store = useProjectStore();
const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const audioRef = ref(null);
const audioFlag = ref(false);

const audioplay = () => {
  if (audioRef.value.paused) {
    audioRef.value.play();

    audioFlag.value = true;
  } else {
    audioRef.value.pause();
    audioFlag.value = false;
  }
};

watch(
  () => store.videoInfoShow,
  (val) => {
    if (val) {
      if (audioRef.value) {
        audioRef.value.pause();
        audioFlag.value = false;
      }
    }
  },
);
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 40% linear-gradient(transparent, rgba(0, 0, 0, 0.15));
}
.outline-parent-bg {
  width: 590px;
  height: 400px;
  margin-top: 78px;
  object-fit: cover;
}
.outline {
  position: absolute;
  top: 78px;
  left: 0;
  z-index: 20;
  display: flex;
  width: 590px;
  height: 400px;
  padding: 64px 68px;
}
.outline-title {
  width: 48px;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  .outline-title-content {
    display: flex;
    align-items: center;
    height: 100%;
    ::v-deep p {
      writing-mode: vertical-lr; /* 从右到左的竖向排列 */
      text-orientation: upright; /* 数字竖排 */
      text-align: center;
      font-family: SourceHanSerifCN-Bold;
      font-size: 20px;
      line-height: 24px;
      letter-spacing: 4px;
      color: #8a7a6a;
      text-shadow: 0.86px 0.86px 0px #d8cbb9;
    }
  }
}
.outline-content {
  width: 401px;
  display: flex;
  flex-direction: column;
  margin-left: 106px;
}
.outline-right {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  position: absolute;
  top: 78px;
  right: 16px;
  z-index: 22;
  .right-content {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: url(https://static.jiyi.show/free/style16/AudioIcon.webp) no-repeat center/100% 100%;
  }
}
.rotate {
  animation: rotate 4s linear infinite;
  @keyframes rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}
.medium {
  width: 100%;
  flex: 1;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: #d9d9d9;
  &:hover img {
    transform: scale(1.2);
  }
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: all 0.3s ease;
  }
}
.outline-subTitle {
  width: 100%;
  text-align: center;
  font-size: 16px;
  line-height: 28px;
  text-align: center;
  margin-bottom: 16px;
  color: #8a7a6a;
  font-family: SourceHanSerifCN;
}
::v-deep .van-text-ellipsis {
  color: #333 !important;
  text-align: justify;
  font-family: 'PingFangSC';
  font-size: 16px;
  line-height: 32px !important;
}
::v-deep .van-text-ellipsis__action::before {
  color: #333 !important;
  font-weight: 800 !important;
}
::v-deep .textMore-box {
  margin-bottom: 16px;
  flex: 1;
  display: flex;
  align-items: center;
}
</style>
